package acwing._1_1AlgorithmBasic._4Math;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._1_1AlgorithmBasic._4Math
 * @File : Q0873.java
 * @Author : WangRuoyu
 * @Date : 2023/4/4 16:49
 */

import java.io.*;

public class Q0873 {
    static int phi(int n) {
        int res = n;
        for (int i = 2; i <= n / i; ++i) {
            if (n % i == 0) {
                res = (res / i) * (i - 1);
                while (n % i == 0){
                    n /= i;
                }
            }
        }
        if (n > 1) {
            res = res / n * (n - 1);
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] words = br.readLine().split(" ");
        int n = Integer.parseInt(words[0]);
        for (int i = 0; i < n; ++i) {
            words = br.readLine().split(" ");
            int k = Integer.parseInt(words[0]);
            wr.write(phi(k) + "\n");
        }
        wr.flush();
    }
}

